package com.kalua.list.harvester.parser;

import java.util.Collections;
import java.util.Set;

import com.google.common.collect.Sets;
import com.kalua.list.domainmodel.product.Product;

public class ProductParseResult {
	
	public static final String UNKNOWN_VENDOR_PRODUCT_ID = "UNKNOWN";
	
	private String vendorLinkProductId;
	private boolean connectionFailed;
	private Throwable failureDetails;
	private Set<Product> products;
	
	public ProductParseResult(	String vendorProductId, 
												Throwable failure) { 
		this.connectionFailed = true; 
		this.vendorLinkProductId = vendorProductId;
		this.failureDetails = failure;
	}
	
	public ProductParseResult(	String vendorProductId, 
												Set<Product> products) {
		this.connectionFailed = false;
		this.vendorLinkProductId = vendorProductId;
		this.products = Sets.newHashSet(products);
	}

	public String getVendorLinkProductId() { return this.vendorLinkProductId; }
	public boolean isConnectionFailed() { return this.connectionFailed; }
	public Throwable getFailureDetails() { return this.failureDetails; }
	public Set<Product> getProducts() { return Collections.unmodifiableSet(this.products); }
}